Skip to content

Conversation

@unidevel
Copy link

This PR fixes:

  1. No error message when loadjson failed
  2. Failed import the sample data from loadjson folder

@unidevel unidevel requested a review from ethanyzhang as a code owner October 29, 2025 21:55
@unidevel unidevel requested a review from yabinma October 29, 2025 21:55
Comment on lines +52 to +54
if len(rows) == 1 && rows[0].ColumnCount() <= 1 {
continue
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When data is empty, usually only has query_id, insert will fail

Comment on lines +57 to +61
placeholders := strings.Repeat("?,", row.ColumnCount())
// Get rid of the trailing comma.
placeholders = placeholders[:len(placeholders)-1]
sqlStmt := fmt.Sprintf("INSERT INTO %s (%s) VALUES (%s)",
table, strings.Join(row.ColumnNames, ","), placeholders)
Copy link
Author

@unidevel unidevel Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes cmd loadjson with the sample data

$ ./pbench_darwin_arm64 loadjson -n test --mysql ./mysql.conf -o ./test ./cmd/loadjson/20240422_013209_00111_k6ve9_shows_schema.json
{"level":"info","output_path":"test/test","time":"2025-10-29T21:58:11Z","message":"output directory"}
{"level":"info","log_path":"test/test/loadjson.log","time":"2025-10-29T21:58:11Z","message":"log file will be saved to this path"}
{"level":"info","parallelism":16,"time":"2025-10-29T21:58:11Z"}
{"level":"info","path":"./cmd/loadjson/20240422_013209_00111_k6ve9_shows_schema.json","time":"2025-10-29T21:58:11Z","message":"start to process file"}
{"level":"error","error":"sql: expected 37 arguments, got 38","path":"./cmd/loadjson/20240422_013209_00111_k6ve9_shows_schema.json","time":"2025-10-29T21:58:12Z","message":"failed to insert event listener record"}
{"level":"info","file_loaded":0,"time":"2025-10-29T21:58:12Z"}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can this happen? I don't understand

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rows is an array of operator stats, when it extract the rows, the first row has 37 column with 37 values, and some of the other rows has 38 columns with 38 values, but the statement is created by the first row, that makes the values not matching for some of the other rows which have 38 columns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants